home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
scope
/
001-025
/
scopedisk13
/
fracgen
/
semi.035
< prev
next >
Wrap
Text File
|
1995-03-18
|
8KB
|
237 lines
FRACTAL GENERATOR 1.0
Copyright (c)1988 Doug Houck
DISTRIBUTION NOTICE
This Fractal Generator is freely redistributable, so you may give
copies to your friends, but you may not charge for it (other than a
modest copying fee).
SOURCE CODE
Due to the fact that this program is laced with code that is part
of commercial products (Doug's Math Aquarium, Doug's Color Commander),
the remaining code would be of little value to you except as examples.
So it has been omitted.
KUDOS
If you derive excessive pleasure from this program, you may send
your appreciation in the form of a $5 bill to:
Doug Houck
922 West Uncas Road
Port Townsend, WA 98368
USA
If this program blows your power supply, crashes your hard disk, or
fails to perform to your expectations, you may send your bills and
criticisms to:
Bit Bucket
Track 81
Daisy Plains, IO 80286
No Modem's Land
BUT WHAT DOES IT DO?
The main idea of this program is very simple. Take a shape composed
of several line segments, and replace each line segment with a small
copy of the entire shape. Continue doing this until you reach the
resolution limit of your screen. For example: (Koch Snowflake)
/\
Seed / \
____/ \____
__/\__
1st Generation \ /
_/\_/ \_/\_
What you have is a self-similar fractal.
GETTING STARTED
There are a number of fractals stored on disk. To get at them,
just hit Load, and double-click on a filename. It will plot automatically.
Hit the Menu button to return to the editing screen.
If you wish edit the shape of a fractal seed, select one of
"Add", "Delete" or "Move" from the edit menu, and manipulate the shape
with the mouse. TIP: Keep the fractal seed simple.
To draw a new fractal, select Draw in the Fractal menu.
For finer control of the fractal, select Parameters in the Fractal
menu. See below for more info on Parameters.
================= The Menu options are explained below. ==================
PROJECT
New Erase the seed (all points) from the screen.
Load Load fractal seed and colors from disk.
Save Save fractal seed to disk.
Quit Quits program.
EDIT
Add Adds a point in the nearest line segment.
Move Moves the nearest point.
Delete Deletes nearest point.
FRACTAL
Draw Draws fractal using current parameters and options.
Parameters Displays current parameters, allows editing.
See below on Parameters
Detail Length of the shortest allowed line segment.
Make larger (5?) for faster drawing.
Depth Maximum amount of times to replace line segment
with copy. Max 70, based on program stack.
PARAMETERS
RECURSION LEVELS means the following parameters are applied on
a level by level (generation) basis, where the first character
applies to the first generation, the second character applies
to the second generation... The parameters for the level are
used BEFORE the line segment parameters.
LINE SEGMENTS means the following parameters are applied to
the individual line segments of the seed shape. The first
character applies to the first line segment (starting from the
left), the second character applies to the second line segment...
REPEATING is applied to each string to make it long enough.
For example:
f = 'ffffffffffffffffffff...'
fr = 'frfrfrfrfrfrfrfrfrfr...'
vii = 'viiviiviiviiviiviivi...'
If invalid characters are present, it defaults to the first
character in the 'f/r' (or whatever) specification.
DIRECTION can be forward (f) or reverse (r). Reversing a shape
means to swap end for end.
It converts __/\ to /\__
FLIP can be either normal (n) or flipped (f). Flip means to
flip the shape along the axis formed by the endpoints of the shape.
It converts __/\ to __
\/
Flip and reverse can be combined, ergo
both convert __/\ to __
\/
VISIBLE can be visible (v) or invisible (i). It is applied to
each segment of the shape numbered from left to right (as the
shape was created).
For instance, 'viv' converts __/\ to __ \
COLOR controls how often the color register is advanced.
For example, '001' would not increment the color on the first
2 levels of recursion, but would advance by 1 on the third level.
EXPERIMENT with each of these controls with depth set to 2 or 3,
a simple shape, varying one parameter at a time.
THE MENU BUTTON
Just clicking the Menu button will return you to the editing window
from the plotting window or parameter window.
============================================================================
'Fractal Will Expand' requester - what it means.
Imagine a line drawn from one endpoint of your shape to the other. If any
one of the lines in your shape is bigger than this imaginary line,
the fractal will expand. The easiest way to fix this is to move your
shape endpoints farther apart, thereby making the component line segments
smaller in comparison.
If you decide to Try It, one of three things may happen.
1. The line drawing routine tries to draw into a far corner of the
Amiga's memory. Corners being what they are, there may be a moron
program there which is confounded by strange new opcodes. (Reader
Problem: Design a program (a la Core Wars) which can withstand the
onslaught of a line drawer gone wild.)
2. You wisely chose a small Depth, and made sure the line segments
are only marginally larger than the shape endpoint-to-endpoint
length. Some wild lines appear on your screen, but nothing blows
up.
3. Time is consumed at the following rate:
Time = (time per line segment)*((number of line segments)^Depth)
Unless you have a time warp handy, you'd best try a different shape.
MORE COMMANDS
If your fractals end up plotting in a corner, you may shift the
seed by pressing the cursor keys. Each press moves the seed 10
pixels.
For ultimate power, you may edit the files in which it saves the
seed formulas with any plain ascii editor.
FOR HACKOIDS
You may also enter the seed shapes directly - here's how.
Select load, and load the file "Con:0/0/200/50/input". It will
give you some "Drawer not Found"s, but hit OK anyhow. You have
just opened the console file on the workbench screen. Pull
down the FracGen screen part way, and the plotting screen too to
expose the "input" window on Workbench.
Now type commands in the "input" window just like they would appear
in a formula file. The two most useful commands are:
Point x y ; Line to this point.
Angle degrees length ; Turn in this direction, and
; draw a line this long.
; This is relative to your current
; heading, a la Turtle Graphics.
I would suggest a sequence like the following for the Koch Snowflake
Point 100 100 ; ; define starting point
Angle 0 75 ; __ ; start pointing thisaway-->
Angle 60 75 ; __/
Angle -120 75 ; __/\
Angle 60 75 ; __/\__
Press <CTRL><\> (control and backslash) to terminate input.
Center the seed with the cursor keys.
SAVING FRACTALS
Feel free to add your own beautiful fractals to this collection.
Before you save the fractal, select the Parameters window, and enter your
name and some notes about your particular fractal.
IMPLEMENTATION
This was coded in Lattice C, and hacked into Manx C, except for a
custom fixed decimal point multiply in Assembly. I use the Motorola
Fast Floating Point library for all the shape manipulation, then do all
the fractal drawing with fixed decimal point arithmetic, which cooks
on multiplication, really flies on addition and conversion to integers.
Actually, the hardest part was the routine to find the nearest line
segment in Add point. It requires a rotation of axes before the distance
can be determined. If you have a large number of points (>10) you will
notice a slight delay as it cranks through all the calculations.
REFERENCE
As usual, I refer you to Benoit B. Mandelbrot's book, The Fractal
Geometry of Nature, W. H. Freeman and Company, 1977. Look especially
around page 43, and at the Koch Snowflake, which inspired this program.
Also, there are numerous shapes spread around the book.